package com.ticket.sass.admin.business.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ticket.sass.admin.business.TicketCheckRecordBusiness;
import com.ticket.sass.admin.dto.input.ticket.TicketCheckRecordListInput;
import com.ticket.sass.admin.dto.output.ticket.TicketCheckRecordListOutput;
import com.ticket.sass.admin.model.PageModel;
import com.ticket.sass.admin.service.impl.TicketCheckRecordServiceImpl;
import com.ticket.sass.admin.util.ModelUtil;
import com.ticket.sass.common.entity.tenant.TicketCheckRecordEntity;
import lombok.AllArgsConstructor;
import org.modelmapper.TypeToken;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author ywb
 * @date 2024-04-15 10:56
 */

@Service
@AllArgsConstructor
@Transactional(rollbackFor = Exception.class)
public class TicketCheckRecordBusinessImpl implements TicketCheckRecordBusiness {
    
    final ModelUtil modelUtil;
    final TicketCheckRecordServiceImpl service;
   
    @Override
    public PageModel<TicketCheckRecordListOutput> list(TicketCheckRecordListInput input) {
        IPage<TicketCheckRecordEntity> page = service.iPage(input);
        List<TicketCheckRecordListOutput> outputs = modelUtil.listToList(
            page.getRecords(),
            new TypeToken<List<TicketCheckRecordListOutput>>(){}.getType()
        );
        return new PageModel<>(page.getTotal(), outputs);
    }
}
